// 品牌管理模块接口
import request from '@/utils/request';
import { Trademark, TrademarkResponseData } from './types';

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark',
  ADD_TRADEMARK_URL = '/admin/product/baseTrademark/save',
  UPDATE_TRADEMARK_URL = '/admin/product/baseTrademark/update',
  DELETE_TRADEMARK_URL = '/admin/product/baseTrademark/remove',
}

// 获取已有品牌的接口
export const reqHasTrademark = (page: number, limit: number) => {
  return request.get<any, TrademarkResponseData>(API.TRADEMARK_URL + `/${page}/${limit}`);
};

// 添加或者修改品牌的接口
export const reqAddOrUpdateTrademark = (data: Trademark) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATE_TRADEMARK_URL, data);
  } else {
    return request.post<any, any>(API.ADD_TRADEMARK_URL, data);
  }
};
// 删除品牌的接口
export const reqDeleteTrademark = (id: number) => {
  return request.delete<any, any>(`${API.DELETE_TRADEMARK_URL}/${id}`);
};
